//
//  CommonTools.h
//  housekeep
//
//  Created by ttouch on 16/5/8.
//  Copyright © 2016年 谭真. All rights reserved.
//

#import <Foundation/Foundation.h>
//#import "CMPopTipView.h"

@interface CommonTools : NSObject

#pragma mark - 应用信息

+ (NSString *)appDisplayName;
+ (NSString *)appBundleName;
+ (NSString *)appVersion;
+ (BOOL)needShowNewFeature;

#pragma mark - 文本计算

/// 计算文字size
+ (CGSize)sizeOfText:(NSString *)text fontSize:(CGFloat)fontSize;
+ (CGSize)sizeOfText:(NSString *)text fontSize:(CGFloat)fontSize width:(CGFloat)width;
+ (CGSize)sizeOfText:(NSString *)text fontSize:(CGFloat)fontSize width:(CGFloat)width height:(NSInteger)height;
+ (CGSize)sizeWithText:(NSString *)text font:(CGFloat)font;
#pragma mark - 正则验证
// 允许汉字，大小写或数字(不限字数)
+(BOOL)inputChineseOrLettersAndNumbersNum:(NSString*)string;
//判断仅输入字母或数字
+(BOOL)inputShouldLetterOrNum:(NSString *)inputString;
//判断是否含有非法字符 yes 有  no没有
+ (BOOL)JudgeTheillegalCharacter:(NSString *)content;
/// 是否是身份证
+ (BOOL)validateIdentityCard: (NSString *)identityCard;
/// 验证手机号
+ (BOOL)isMobileNumber:(NSString *)mobileNum;
/// 验证电子邮件
+ (BOOL)isEmail:(NSString *)email;
/// 验证qq
+ (BOOL)isQqNumber:(NSString *)qqNum;
/// 验证银行卡号
+ (BOOL)isBankCardNumber: (NSString *)bankCardNumber;

#pragma mark - 颜色相关

/// 随机颜色
+ (UIColor *)colorLightRandom;
/// 以UIColor生成一张UIImage
+ (UIImage *)imageCreateWithColor:(UIColor *)color;
+ (UIImage *)imageCreateWithColor:(UIColor *)color size:(CGSize)size;

#pragma mark - 图片相关

/// 压缩图片尺寸，方便上传服务器
+ (UIImage *)imageScale:(UIImage *)img size:(CGSize)size;

#pragma mark - 时间戳 <-> 时间字符串 转换
+ (NSString *)getTimeStrBytimeSt:(NSString *)timeStamp;
/** 时间戳 -> 时间字符串 dateFormat默认为yyyy-MM-dd*/
+ (NSString *)getTimeStrBytimeStamp:(NSString *)timeStam;
+ (NSString *)getTimeStrBytimeStamp:(NSString *)timeStamp dateFormat:(NSString *)dataFormat;

/**时间字符串 -> 时间戳 dateFormat默认为MM-dd*/
+(NSString *)getTimeMothWithDayStr:(NSString *)timeStr;

+ (NSString *)strWithTimestamp:(long long)timestamp;
#pragma mark - 富文本字符串处理

/// 返回NSAttributedString，左侧String为灰色，右侧为TZMainColor
+ (NSAttributedString *)getAttributedStringWithFirstString:(NSString *)firstStr firstColor:(UIColor *)firstColor lastString:(NSString *)lastStr lastColor:(UIColor *)lastColor fontSize:(CGFloat )fontSize;

#pragma mark - 距离计算

/// 2个坐标距离
+ (NSString *)locationWithLatitude:(NSString *)firstLatitude withLongitude:(NSString *)firstLongitude WithLatitude:(NSString *)secondLatitude withLongitude:(NSString *)secondLongitude;

#pragma mark - 其他

/// 防止nil，如果是nil,返回空字符串
+ (NSString *)avoidNil:(NSString *)str;
/// 检查value是否为空，是空则返回NO,非空返回YES
+ (BOOL)isNotNull:(id)value;
+ (BOOL)hasLength:(id)value;
/// 判断文件夹是否存在
+ (BOOL)isExistFile:(NSString *)path;
/// 通用的警告框提示
+ (void)alertFormatofTitle:(NSString *)title withMessage:(NSString *)message withCancelBtnTitle:(NSString *)cancelTitle;

// 签到提示框
//+ (void)showSignResultWithPoint:(NSString *)point;
// 字符串汉子转出首字母
+ (NSString *)getFirstLetterFromString:(NSString *)aString;

// 根据字符不规则排版View
+ (CGFloat)configViewForStrViewArr:(NSMutableArray *)viewArr strArr:(NSArray *)strArr;

// 设置Label行间距并自适应后取出高度
+ (CGFloat)configParagraphLbl:(UILabel *)lbl;




// 读缓存
+(float)readCacheSize;
// 清除缓存
+(NSString *)clearFile;

+(BOOL)isEmpty:(NSString *)str;
@end
